using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using UlyssesAgenda.Repositories.GameObjects;
using UlyssesAgenda.Repositories;
using UlyssesAgenda.CoreLib;
using UlyssesAgenda.GameEngine;

namespace UlyssesAgenda.Web.Controllers
{
    public class GameObjectController : Controller
    {
        private GameObjectRepository objectRepository;

        public GameObjectController() : this(null) { }

        public GameObjectController(GameObjectRepository repository)
        {
            if (repository == null)
            {
                objectRepository = RepositoryFactory.GetRepository<GameObjectRepository>();
            }
            else
            {
                objectRepository = repository;
            }
        }

        //
        // GET: /GameObject/

        public ActionResult Index()
        {
            GameObjectInfo[] objects = objectRepository.GetGameObjects();
            return View(objects);
        }

        public ActionResult Create()
        {
            return View();
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(GameObjectInfo newObject)
        {
            objectRepository.CreateGameObject(newObject.CanonicalName);
            return RedirectToAction("Index");
        }

        public ActionResult Details(string id)
        {
            GameObjectInfo goInfo = objectRepository.GetGameObject(id);
            Engine e = new Engine();           

            return View(goInfo);
        }



    }
}
